package com.concurrency.cyclicBarrier;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

public class Worker extends Thread{
	CyclicBarrier barrier;
	
	public Worker(CyclicBarrier barrier){
		this.barrier = barrier;
	}

	
	public void run(){

		try {
			System.out.println(Thread.currentThread().getName()+"start Work");
			Thread.sleep(4000);
			System.out.println(Thread.currentThread().getName()+"end Work");
			barrier.await();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
